package org.example.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class RedisMessageQueue {


    @Autowired
    @Qualifier("redisTemplate1")
    private RedisTemplate<String, Object> redisTemplate;

    public void sendMessage(String queueName, String message) {
        redisTemplate.opsForList().leftPush(queueName, message);
    }

    public Object receiveMessage(String queueName) {
        return redisTemplate.opsForList().rightPop(queueName);
    }

    public void convertAndSend(String channel, String message) {
        redisTemplate.convertAndSend(channel, message);
    }
}
